package exemplos;

import br.edu.fvs.principal.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;

public class ExemploCheckRadio extends Activity implements OnClickListener {
	EditText textNome;
	Button bt;
	RadioGroup radioConcordaGroup;
	RadioButton radioConcordaButton;
	CheckBox cbrecebeEmail;

	protected void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		setContentView(R.layout.check_radio_form);
		textNome = (EditText) findViewById(R.id.textNome);
		bt = (Button) findViewById(R.id.buttonEnviar);
		bt.setOnClickListener(this);
		radioConcordaGroup = (RadioGroup) findViewById(R.id.group1);
		cbrecebeEmail = (CheckBox) findViewById(R.id.checkReceberEmail);
	}

	@Override
	public void onClick(View arg0) {
		// TODO Auto-generated method stub
		int selectedId = radioConcordaGroup.getCheckedRadioButtonId();
		radioConcordaButton = (RadioButton) findViewById(selectedId);
		Toast.makeText(this, "Nome: " + textNome.getText().toString() +
				"\n Concorda: " + radioConcordaButton.getText().toString() +
				"\n Receber Email: " + cbrecebeEmail.isChecked(), Toast.LENGTH_SHORT).show();
	}

}
